home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / BIASAXON / ADJSIGA.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.3 KB  |  45 lines

  1. // Dynamic link library implementation of SigmoidAxon with adaptible slope
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /***********************************/
  6. /* Forward activation of component */
  7.  
  8. __declspec(dllexport) void performBiasAxon(
  9.     DLLData    *instance,    // Pointer to instance data
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols,        // Number of columns of PEs in the layer
  13.     NSFloat    *bias        // Pointer to the layer's bias vector, one for each PE
  14.     )
  15. {
  16.     int i, length=rows*cols;
  17.     NSFloat *beta = getWeights(instance);
  18.  
  19.     for (i=0; i<length; i++) {
  20.         if (beta[i] < 0.5f)
  21.             beta[i] = 0.5f;
  22.         data[i] = 1.0f / (1.0f + (NSFloat)exp(-(beta[i]*data[i] + bias[i])));
  23.     }
  24. }
  25.  
  26. /******************************************/
  27. /* Management of instance data (OPTIONAL) */
  28.  
  29. __declspec(dllexport) DLLData *allocBiasAxon(
  30.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  31.     int     rows,            // Number of rows of PEs in the layer
  32.     int     cols            // Number of columns of PEs in the layer
  33.     )
  34. {
  35.     DLLData *instance = allocDLLInstance(oldInstance);
  36.     setWeights(instance, rows*cols);
  37.     return instance;
  38. }
  39.  
  40. __declspec(dllexport) void freeBiasAxon(DLLData *instance)
  41. {
  42.     freeDLLInstance(instance);
  43. }
  44.  
  45.